<template>
	<view class="qj-detail">
		<view class="my-list2">
			<view v-if="!obj"><u-empty text="没有数据"></u-empty></view>

			<view class="ml-item-detail" v-else>
				<view class="i-title">
					<view>
						<view class="tip-icon"></view>{{obj.abnormalityType == '0'?'违章':'事故'}}
					</view>

				</view>
				<view class="i-footer">
					<view>
						状态：{{obj.abnormalityStatus =='WAIT_DRIVER_OPER'?'待驾驶员处理':obj.abnormalityStatus =='WAIT_MANAGER_CHECK'?'待管理员审核':obj.abnormalityStatus =='CHECKED'?'审核通过':obj.abnormalityStatus =='REFUESD'?'审核不通过':'' }}
					</view>
				</view>
				<view class="i-row">

					<view class="i-row-textarea">
						<view class="r-title">处理图片<label class="r-title-tip">（最多上传6张图片）</label></view>
						<view class="r-con">
							<u-upload ref="jyjzUf" width="200" height="200" max-count="6" :file-list="fm.uflist"
								:action="fm.ufAction" :header="fm.ufHeader" :name="'file'"
								:form-data="{ftype: 'DRIVER_DISPOSE_IMG',}" :max-size="1024*1024*30"></u-upload>
						</view>
					</view>
				</view>
				<view class="i-row">
					<view class="r-title">备注：</view>
					<u-input v-model="data.proveRemark" :type="'textarea'" :custom-style="{'color': '#00C3CE'}"
						:clearable="false" :auto-height="true" :height="150" :maxlength="1000"
						:placeholder="'请填写您的请假事由，最多输入1000个字'" />
				</view>



				<view class="i-btns">

					<view class="btn ok" :data-obj="obj.id" @click="setDelQjMd">提交处理</view>
				</view>

			</view>
		</view>

		<u-modal :title="delMd.title" :confirm-style="{'color': '#00c3ce'}" v-model="delMd.state"
			:show-cancel-button="true" @confirm="okDelQj">
			<view class="c-yellow" :style="{'padding': '20rpx', 'text-align': 'center'}">{{delMd.tip}}</view>
		</u-modal>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: {
					id: '',
					proveRemark: '',
					proveUrl: '',
				},
				fm: {
					// 文件上传地址
					ufAction: this.C.upfileUrl,
					// 文件上传请求头信息
					ufHeader: {
						'token': uni.getStorageSync(this.C.uuid)
					},
					uflist: [],
				},
				abnormalityUrl_list: [],
				proveUrl_list: [],
				// 详情
				obj: null,
				// 删除--弹框
				delMd: {
					state: false,
					title: '删除提示',
					tip: '', // 提示内容
					obj: null, // 参数对象
				},
				imagee: "",
				show: false,
			}
		},
		onLoad(ps) {
			this.data.id = ''
			this.data.proveRemark = ''
			this.data.proveUrl = ''
			this.fm.uflist = []
			this.getQjDetail(ps.id);

		},
		methods: {
			image_btn(e) {
				this.show = true
				this.imagee = e

			},
			// 获取-请假详情
			getQjDetail(id) {
				let that = this,
					U = that.U;

				U.qloading('加载中...');
				that.$u.api.getVehicleAbnormalityById({
					id: id
				}).then(res => {
					if (res.code == 1) {
						U.qclose();

						if (res.code != 1) {
							U.qerror(res.msg);
						} else {
							that.obj = res.data;
							that.abnormalityUrl_list = res.data.abnormalityUrl.split(",")
							that.proveUrl_list = res.data.proveUrl.split(",")
						}
					}
				}).catch(err => {
					U.qclose();
				});
			},
			// 删除-
			setDelQjMd(e) {
				let that = this,
					U = that.U;

				that.delMd = {
					state: true,
					title: '提示',
					tip: '确定提交？',
					obj: e.currentTarget.dataset.obj
				};
			},
			// 确认删除-
			okDelQj() {
				let that = this,
					U = that.U,
					id = that.delMd.obj;
				let ps = {
					id:'',
					proveRemark:'',
					proveUrl :'',
				}
				ps.id = that.obj.id
				ps.proveRemark = that.data.proveRemark
				let uflist = that.$refs.jyjzUf.lists
				if (uflist.length == 0) {
				return	U.qinfo('至少需要上传一张加油小票图片');
				} else {
					let fids = [];
					uflist.forEach(it => {
						if (it.response && it.response.data) fids.push(it.response.data.file.url);
					});
				
					console.log('加油记账图片', uflist, fids);
				
					if (fids.length == 0) {
						return U.qinfo('上传图片' + uflist.length + '张，成功' + fids.length + '张');
					} else {
						ps.proveUrl = fids.join(',');
				
					}
				}
				
				that.$u.api.disposeAbnormality(ps).then(res => {
					if (res.code == 1) {
						U.qsuccess(res.msg, 3000, function() {
							// 隐藏弹框
							that.delMd.state = false;

							// 调用父级onLoad中的刷新方法
							uni.$emit('refQjList');
							// 返回上一页
							uni.navigateBack({
								delta: 1
							});
						});
					} else {
						U.qerror(res.msg);
					}
				});
			},
		}
	}
</script>

<style>

</style>